package cn.ad.server.common.utils.monitor.impl;

import cn.ad.server.common.utils.monitor.CallPoint;

public class DefaultCallPoint extends DefaultTransaction implements CallPoint{
	
	private String className = null;
	
	private String methodName = null;
	
	public DefaultCallPoint(String name) {
		super(name);
	}
	
	public DefaultCallPoint(String className, String method){
		StringBuilder sb = new StringBuilder();
		sb.append("C-").append(className).append(".").append(method);
		setName(sb.toString());
		this.className = className;
		this.methodName = method;
	}

	/* (non-Javadoc)
	 * @see cn.ad.server.web.utils.monitor.CallPoint#getClassName()
	 */
	@Override
	public String getClassName() {
		return className;
	}

	/* (non-Javadoc)
	 * @see cn.ad.server.web.utils.monitor.CallPoint#getMethod()
	 */
	@Override
	public String getMethod() {
		return methodName;
	}

	/* (non-Javadoc)
	 * @see cn.ad.server.web.utils.monitor.CallPoint#getSignature()
	 */
	@Override
	public String getSignature() {
		return getName();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(getName())
		  .append("\t")
		  .append(getDuration())
		  .append("\t")
		  .append(getMethod())
		  .append("\t")
		  .append(getClassName());
		return sb.toString();
	}
}
